#pragma once 
//----------------------------------------------------------------------------------------------------------------
//			Filename:		MeshObject.h
//			  Author:		Adrian De Barro
//			    Date:		12/08/2015
//----------------------------------------------------------------------------------------------------------------
//			  Status: REFACTORING
//----------------------------------------------------------------------------------------------------------------
#include <string>
#include <vector>

#include "..\CoreClasses\RGBObject\RGBColor.h"
#include "..\Material\Textures\Texture.h"
#include "..\Material\Textures\SolidColor.h"
#include "..\Material\Textures\ImageTexture.h"

class ShadeRec;

namespace Engine
{
	class Light;
	class Tracer;

	enum SURFACE_TYPE
	{
		DIFF,
		REFL,
		GLOSSY,
	};
	//----------------------------------------------------------------------------------------------------------------
	//			Class Name: ObjectMesh
	//		   Description: Represent a TRIS. Concrete implementation of GeometricObjects
	//----------------------------------------------------------------------------------------------------------------
	//			    Status: REFACTORING
	//----------------------------------------------------------------------------------------------------------------
	class Material
	{
	public:
		//----------------------------------------------------------------------------------------------------------------
		//		 Method Name: CONSTRUCTOR
		//		Return Value: VOID
		//		  Parameters: Surface_Type
		//			  Status: READY
		//----------------------------------------------------------------------------------------------------------------
		Material(SURFACE_TYPE p_type)
		{
			m_type = p_type;
		}
		//----------------------------------------------------------------------------------------------------------------
		//		 Method Name: CONSTRUCTOR
		//		Return Value: VOID
		//		  Parameters: VOID
		//			  Status: READY
		//----------------------------------------------------------------------------------------------------------------
		Material(void)
		{
			m_type = DIFF;
		}
		//----------------------------------------------------------------------------------------------------------------
		//		 Method Name: CONSTRUCTOR
		//		Return Value: VOID
		//		  Parameters: Texture*
		//			  Status: READY
		//----------------------------------------------------------------------------------------------------------------
		Material(Texture* p_currentTexture)
		{
			m_type = DIFF;
			m_materialTexture = p_currentTexture;
			m_containsTexture = p_currentTexture->ContainsTexture();
		}
		//----------------------------------------------------------------------------------------------------------------
		//		 Method Name: Shade
		//		Return Value: VOID
		//		  Parameters: CollisionDetails,  vector<Light*>& sceneLights, Tracer*, Light* (optional)
		//			  Status: READY
		//----------------------------------------------------------------------------------------------------------------
		virtual RGBColor Shade(ShadeRec& sr, std::vector<Light*>& sceneLights, Tracer* p_tracerPtr, RGBColor& p_colorAtPoint, Light* ambient = NULL) = 0;
		//----------------------------------------------------------------------------------------------------------------
		//		 Method Name: GetColor
		//		Return Value: VOID
		//		  Parameters: RGBColor
		//			  Status: READY
		//----------------------------------------------------------------------------------------------------------------
		RGBColor Getcolor()
		{
			float x = 0, y = 0;
			return m_materialTexture->GetColor(x, y);
		}
		//----------------------------------------------------------------------------------------------------------------
		//		 Method Name: GetColor
		//		Return Value: RGBColor
		//		  Parameters: float x, float y
		//			  Status: READY
		//----------------------------------------------------------------------------------------------------------------
		RGBColor GetColor(float p_x, float p_y)
		{
			return m_materialTexture->GetColor(p_x, p_y);
		}
		//----------------------------------------------------------------------------------------------------------------
		//		 Method Name: SetColor
		//		Return Value: VOID
		//		  Parameters: RGBColor 
		//			  Status: READY
		//----------------------------------------------------------------------------------------------------------------
		void SetColor(RGBColor p_cD)
		{
			m_materialTexture = new SolidColor(p_cD);
		}
		//----------------------------------------------------------------------------------------------------------------
		//		 Method Name: SetTexture
		//		Return Value: VOID
		//		  Parameters: RGBColor
		//			  Status: READY
		//----------------------------------------------------------------------------------------------------------------
		void SetTexture(RGBColor p_color)
		{
			m_materialTexture = new SolidColor(p_color);
		}
		//----------------------------------------------------------------------------------------------------------------
		//		 Method Name: SetTexture
		//		Return Value: VOID
		//		  Parameters: String path
		//			  Status: READY
		//----------------------------------------------------------------------------------------------------------------
		void SetTexture(string p_path)
		{
			m_materialTexture = new ImageTexture(p_path);
		}
		//----------------------------------------------------------------------------------------------------------------
		//		 Method Name: GetType
		//		Return Value: SURFACE_TYPE
		//		  Parameters: VOID
		//			  Status: READY
		//----------------------------------------------------------------------------------------------------------------
		SURFACE_TYPE GetType()
		{
			return m_type;
		}
		//----------------------------------------------------------------------------------------------------------------
		//		 Method Name: SetType
		//		Return Value: VOID
		//		  Parameters: SURFACE_TYPE
		//			  Status: READY
		//----------------------------------------------------------------------------------------------------------------
		void SetType(SURFACE_TYPE p_type)
		{
			m_type = p_type;
		}
		//----------------------------------------------------------------------------------------------------------------
		//		 Method Name: GetReflectionConstant
		//		Return Value: float
		//		  Parameters: VOID
		//			  Status: READY
		//----------------------------------------------------------------------------------------------------------------
		float GetReflectionConstant()
		{
			return m_Kr;
		}
		//----------------------------------------------------------------------------------------------------------------
		//		 Method Name: SetReflectionConstant
		//		Return Value: VOID
		//		  Parameters: float 
		//			  Status: READY
		//----------------------------------------------------------------------------------------------------------------
		void SetReflectionConstant(float p_Kr)
		{
			m_Kr = p_Kr;
		}
		//----------------------------------------------------------------------------------------------------------------
		//		 Method Name: GetMaterialName
		//		Return Value: string
		//		  Parameters: VOID
		//			  Status: READY
		//----------------------------------------------------------------------------------------------------------------
		std::string GetMaterialName()
		{
			return m_materialName;
		}
		//----------------------------------------------------------------------------------------------------------------
		//		 Method Name: SetTexture
		//		Return Value: VOID
		//		  Parameters: Texture*
		//			  Status: READY
		//----------------------------------------------------------------------------------------------------------------
		void SetTexture(Texture* p_texture)
		{
			m_materialTexture = p_texture;
		}
		//----------------------------------------------------------------------------------------------------------------
		//		 Method Name: SetMaterialName
		//		Return Value: VOID
		//		  Parameters: string 
		//			  Status: READY
		//----------------------------------------------------------------------------------------------------------------
		void SetMaterialName(std::string p_materialName)
		{
			m_materialName = p_materialName;
		}

	protected:
		Texture* m_materialTexture;
		bool m_containsTexture;
		SURFACE_TYPE m_type;
		float m_Kr;
		std::string m_materialName;
	};
	//----------------------------------------------------------------------------------------------------------------
}
//----------------------------------------------------------------------------------------------------------------
